﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;

namespace Heyo.Class.Helper.Encryption
{
    public class Base64Helper
    {
        public static byte[] GetDataFromString(string str,Func<char,char> switchFunc=null)
        {
            char[] buffer = switchFunc!=null ? str.Select(switchFunc).ToArray() : str.ToCharArray();
            return Convert.FromBase64CharArray(buffer,0,buffer.Length);
        }

        public static string GetStringFromData(byte[] buffer, Func<char,char> switchFunc = null)
        {
            if (switchFunc != null)
                return new string(Convert.ToBase64String(buffer, 0, buffer.Length).Select(switchFunc).ToArray());
            return Convert.ToBase64String(buffer, 0, buffer.Length);
        }
    }
}
